﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DA
{
    public class NapChupDA:BaseConnection
    {
         public SqlDataAdapter danhSachNapChupAdapter { set; get; }
         public NapChupDA()
         {
          
         }
         public DataSet timKiemNapChup(string maNapChup)
         {
             DataSet ds = new DataSet();
             String sqlStatement = "";
             sqlStatement = "SELECT MaNapChup, TenNapCHup, DienGiai, SoLuong, SoLuongDangSuDung, HinhAnh, KichThuoc, GhiChu";
             sqlStatement += " FROM NapChup";
             sqlStatement += " WHERE MaNapChup = '" + maNapChup + "'";

             openConnect();

             SqlCommand cmd = new SqlCommand(sqlStatement, con);
             danhSachNapChupAdapter = new SqlDataAdapter(cmd);
             danhSachNapChupAdapter.SelectCommand = cmd;
             SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachNapChupAdapter);
             danhSachNapChupAdapter.Fill(ds, "NapChup");
             closeConnect();
             return ds;        
         }

         public DataSet layDanhSachNapChup()
         {
             openConnect();
             String sqlStm = "SELECT * FROM NapChup";

             SqlCommand cmd = new SqlCommand(sqlStm, con);
             danhSachNapChupAdapter = new SqlDataAdapter(cmd);
             danhSachNapChupAdapter.SelectCommand = cmd;
             SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachNapChupAdapter);
             DataSet ds = new DataSet();
             danhSachNapChupAdapter.Fill(ds, "NapChup");
             closeConnect();
             return ds;
         }
    }
}
